package com.example.clublesson01.loginblocking


import android.content.Context
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.annotation.Interceptor
import com.alibaba.android.arouter.facade.callback.InterceptorCallback
import com.alibaba.android.arouter.facade.template.IInterceptor
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.SPUtils

@Interceptor(priority = 1)
class LoginBlocking: IInterceptor {
    override fun init(context: Context?) {

    }
    override fun process(postcard: Postcard?, callback: InterceptorCallback?) {
        if("/app/login/ChongActivity" == postcard?.path ||
            "/app/login/ChongSendCodeActivity" == postcard?.path ||
            "/app/login/LoginPhoneActivity" == postcard?.path ||
            "/app/login/SendCodeActivity" == postcard?.path ||
            "/app/login/WangLoginActivity" == postcard?.path ||
            "/app/banner/WelBannerActivity" == postcard?.path ||
            "/app/login/YzmActivity" == postcard?.path ||
            "/app/login/LoginActivity" == postcard?.path ||
            SPUtils.getInstance().getString("token").isNotEmpty()){
            callback?.onContinue(postcard)
        }else{
            ARouter.getInstance().build("/app/login/LoginPhoneActivity").navigation()
        }
    }


}